\subsection{Linked List Searcher}
The Linked List data structure is a simple way of storing data in a line of
linked elements. The Linked List consists of a data \texttt{value}, in this case
a word, and a link (\texttt{next}) to the next linked list element in the list.
The final element in the linked list will not point towards another linked
list element and therefore have \texttt{null next} pointer.\\

\begin{figure}
\begin{center}
\includegraphics[scale=1.0]{../Searchers/linkedlistfigure1.pdf}
\end{center}
\caption{Shows an example of a linked list \label{linkedlistfigure1}}
\end{figure}
When creating a new element in the Linked List the \texttt{put} method is called
with a string as parameter. The new element is then created with the string as
its \texttt{value} and next pointing to \texttt{null}.  If the linked list is
empty and the new element hence is the first added to the list, the pointer towards the first element
(\texttt{data}) in the linked list is pointed towards the new element and
thereby setting the new element to be the first element in the linked list. If
the new element is not the first element in the linked list it will be added to the end of the list.
In order to put the new element at the end of the linked list the \texttt{last
List Element} is assigned to the new element making the new element the last in
the list.\\

\begin{figure}
\centering
\subfloat[A
new element is
created]{\includegraphics[scale=1.0]{../Searchers/linkedlistfigure3.pdf}}
\hspace{15}
\subfloat[The \texttt{last List
Element} is
assigned to
the new
element]{\includegraphics[scale=1.0]{../Searchers/linkedlistfigure4.pdf}}
\caption{Creating a new element and setting it at the end of the list \label{createlinkedlist}}
\end{figure}
The \texttt{put method} in figure \ref{linked56-66} adds a new element to
the linked list.\\

\begin{figure}
\lstinputlisting[firstline=56,lastline=66,firstnumber=56]{../../src/model/searchers/linkedListSearcher/LinkedListSearcher.java}
\caption{Adds an element to the linked list (from
\texttt{LinkedListSearcher} 56-66)\label{linked56-66}}
\end{figure}
The \texttt{get method} sees if a word exists in the linked list. It starts by
setting the \texttt{current} linked list element to the first in the list, the
URL value to \texttt{"No page set"} and the linked list to store the results is
set to \texttt{null} to prevent old results to influencing the search.\\ The
method then runs through each element in the list. If the word is a URL, i.e. starts with \texttt{ "*PAGE:"}, it is stored as the current URL. If it is a word it is compared to the search criteria and if it matches the current URL it
is added to the list of results if it is not the last URL added. If it is the
last URL added the word is skipped as this \texttt{get} method does not count occurrences. It only shows on which pages the word exists.
\\
When searching for a word in the linked list the entire list needs to be looped
through using the \texttt{get} method. This makes the data structure very
inefficient if the linked list is long, i.e. the data set is big. Searching for
a word will then take a long time to complete regardless of the placement of the
element in the list as it always will need to loop through the entire list. \\
The \texttt{get} method in figure \ref{linked82-102} searches for a word in the
linked list.\\

\begin{figure}
\lstinputlisting[firstline=82,lastline=102,firstnumber=82]{../../src/model/searchers/linkedListSearcher/LinkedListSearcher.java}
\caption{Gets an element from the linked list (from
\texttt{LinkedListSearcher} 82-102)\label{linked82-102}}
\end{figure}
The linked list data structure is fast to create. When a new word is loaded a new element is created and put at the end of the linked list. In other words the data handling is minimal when creating the linked list. 
On the down side it is time consuming when you wish to search for data in the linked list. 
 The entire linked list will need to be looped through and a new linked list created with
  the results. The new linked list with the results will contain the URLs where the word was found.  
